﻿using System;
namespace Kis.Xroad.Eu {
    
    
    [global::Xtee.Core.Attributes.XmlTypeAttribute(Name="AbstractInherited", Namespace="http://kis.x-road.eu/", Target=typeof(AbstractInherited))]
    public class AbstractInheritedSerializer : global::Kis.Xroad.Eu.AbstractSerializer {
        
        public AbstractInheritedSerializer(AbstractInherited clazz) : 
                base(clazz) {
        }
        
        protected new AbstractInherited clazz {
            get {
                return ((AbstractInherited)(base.clazz));
            }
        }
        
        public override void WriteXmlAttributes(global::Xtee.Core.IXteeXmlWriter Writer) {
            base.WriteXmlAttributes(Writer);
        }
        
        public override void WriteXml(global::Xtee.Core.IXteeXmlWriter Writer) {
            base.WriteXml(Writer);
            Writer.WriteStartElement("elem2");
            if (clazz.Elem2!=null) {
                Writer.WriteString(new global::Xtee.Core.Schema.XsdString(((string)(clazz.Elem2))).ToString());
            }
            else {
                throw new global::Xtee.Core.Exceptions.NillableNotAllowedException("Nullable is not allowed for element : Elem2");
            }
            Writer.WriteEndElement();
        }
        
        public override void ReadXmlAttributes(global::Xtee.Core.IXteeXmlReader Reader) {
            base.ReadXmlAttributes(Reader);
        }
        
        public override void ReadXml(global::Xtee.Core.IXteeXmlReader Reader) {
            base.ReadXml(Reader);
            if (Reader.LocalName=="elem2") {
                if (Reader.IsElementNil()) {
                    throw new global::Xtee.Core.Exceptions.NillableNotAllowedException(">>AbstractInherited>elem2");
                }
                clazz.Elem2 = new global::Xtee.Core.Schema.XsdString(Reader.ReadElementString("elem2")).Value;
            }
            else {
                throw new global::Xtee.Core.Exceptions.UnExpectedElementException(">>AbstractInherited>elem2", Reader.LocalName);
            }
        }
    }
}
